package com.example.travel.Controller;

import com.example.travel.Service.TopicServer;
import com.example.travel.domain.TestmodelTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 功能：
 * 作者：lln
 * 日期：2025/3/25 16:32
 */
@RestController
@RequestMapping("/topic")
public class TopicController {
    @Autowired
    private TopicServer topicServer;

    //发布话题
    //http://localhost:8080/topic/add?topic=topic&content=content&author=author&authorid=authorid&authorimg=authorimg&contentimg=contentimg
    @GetMapping("/add")
    public int addTopic(@RequestParam String topic, @RequestParam String content, @RequestParam String author, @RequestParam int authorid, @RequestParam String authorimg, @RequestParam String contentimg){
        TestmodelTopic topic1 = new TestmodelTopic();
        topic1.setTopic(topic);
        topic1.setContent(content);
        topic1.setAuthor(author);
        topic1.setAuthorid(authorid);
        topic1.setAuthorimg(authorimg);
        topic1.setContentimg(contentimg);
        topic1.setShow(2);
        topic1.setTime(new Date());
        topic1.setUp(0);
        return topicServer.addTopic(topic1);
    }
}

